@echo off
chcp 65001 >nul
color 0A
setlocal enabledelayedexpansion
set version=251019
title mwtool %version%
:: utf-8 编码


rem 重命名脚本
rem 
rem 更新代码以文件夹名称设置菜单名称
rem 支持.efi格式引导
rem 支持在线更新
rem 优化代码
rem 删除创建虚拟机脚本


set error=输入错误，请重新输入
set return=按任意建返回


:start

echo *****************************************************
echo *
echo *  最新版本%Newversion%
echo *
echo *  当前版本%version%
echo *
echo *  1. 设置镜像菜单 menu.config
echo *
echo *  2. 设置引导菜单 vd.config
echo *
echo *  Q. 退出
echo *
echo *  U. 更新此脚本
echo *
echo *****************************************************
choice /c 12uq /m "请输入:" /n
if errorlevel 4 exit
if errorlevel 3 call:update-config
if errorlevel 2 call:Makefile-vd
if errorlevel 1 call:Makefile-menu
goto :eof

:Makefile-vd
echo *****************************************************
echo *
echo *	在弹出窗口选择镜像所在磁盘
echo *
echo *****************************************************

rem 弹出选择路径
 
for /f "delims=" %%f in ('mshta "%~f0"') do set vdpath=%%~df

rem 进入文件夹
for %%i in (%vdpath%) do if exist %%i\ pushd %%i\

rem 查找菜单路径
set /A a=0
for /r %%i in (*u.config *r.config) do (set /A a+=1 & set include[!a!]=include %%~pnxi)

rem 
if %a% EQU 0 (echo 找不到文件 & echo %return% & pause > nul & goto start)

rem 输出到文件
                            (echo.#
                             echo.# xish.cc
                             echo.#
                             echo.# Multiware（云固件）
                             echo.#
 for /l %%i in (1,1,!a!) do (echo.#
                             echo.!include[%%i]!))>vd.config

rem 显示输出结果
echo ---------------------------------------------------
type vd.config
echo ---------------------------------------------------
echo.
echo 以上是本次扫描的内容
echo 保存在%cd%vd.config
echo.
echo %return%
pause
cls
goto start
exit
goto :eof

 
:Makefile-menu
echo ****************************************************
echo *
echo *	在弹出窗口选择镜像所在文件夹
echo *
echo ****************************************************

for /f "delims=" %%f in ('mshta "%~f0"') do pushd %%f

:png 
echo.
echo ---搜索到以下图标文件---
rem 设置搜索图标文件格式
if exist *.png (
set icon=*.png
set /a a=0
for /f "usebackq delims=" %%i in (`dir /b/a-d !icon!`) do (set /a a+=1 & set icons[!a!]=%%i & echo. !a!. %%i)
if !a! EQU 1 set icon1=!icons[1]!
if !a! GTR 1 ( set /p t=请选择:
if !t! LSS 1   echo %error% &goto png
if !t! GTR !a! echo %error% &goto png
for /l %%n in (1,1,!t!) do (set icon1=!icons[%%n]!)))else echo. 找不到图标文件 &echo. 按任意建跳过 &pause>nul


:vdisk
echo.
echo. ---搜索到以下镜像文件---

set /a b=0
for /f "usebackq delims=" %%i in (`dir /b/a-d *.efi *.vhd *.iso *.img`) do (set /a b+=1 & set vdisks[!b!]=%%i & echo. !b!. %%i)
if !b! equ 0 (echo.找不到镜像文件
              echo.%return%
              pause>nul
              goto Makefile-menu)
if !b! EQU 1 set vdisk=!vdisks[1]!
if !b! GTR 1 ( set /p t=请选择:
if !t! LSS 1   echo.%error% &goto vdisk
if !t! GTR !b! echo.%error% &goto vdisk
for /l %%n in (1,1,!t!) do (set vdisk=!vdisks[%%n]!))


rem 设置文件夹名称为菜单名称

set menu=%cd%
set menu=%menu:\= %
rem echo %menu%
for %%m in (%menu%) do set menu=%%m
if /i %vdisk:~-3% equ efi (set menuout=loader.config) else set menuout=menu.config


rem 输出到文件
                                (echo.# xish-cc
                                 echo.# %menu%
                                 echo.#
                                 echo.# UUID:
                                 echo.# SHORT ID:
                                 echo.#
                                 echo.menuentry "%menu:~0,14%" {
                                 echo.	icon "%icon1%"
      if /i %vdisk:~-3% equ efi (echo.	loader "%vdisk%"
                          )else (echo.	vdisk "%vdisk%")
      if /i %vdisk:~-3% neq efi (
      if /i %vdisk:~-3% equ hdx (echo.	vdtype vhdx
)else if /i %vdisk:~-3% equ img (echo.	vdtype raw
                          )else (echo.	vdtype %vdisk:~-3%))
     if /i %vdisk:~0,3% equ win (
      if /i %vdisk:~-3% neq iso (echo.	ostype Windows))
                                 echo.})>%menuout%

echo.
echo ---本次生成的内容---
echo ----------------------------------------------------
type %menuout%
echo ----------------------------------------------------
echo.
echo 保存在%cd%\%menuout%
echo.
echo.%return%
pause>nul
cls
goto start
goto :eof





rem 下载到当前文件夹
curl -O https://gitee.com/xish-cc/mw.config/raw/master/mwtool.cmd





<script>
var Shell = new ActiveXObject("Shell.Application");
var MyPC = 17
var Folder = Shell.BrowseForFolder(0, "Please select a folder", 0, MyPC); //起始目录为：我的电脑
if (Folder != null) {
    Folder = Folder.items();
    Folder = Folder.item();
    Folder = Folder.Path;
    new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(Folder);
}
close();
</script>  